INSERT
INTO
c1_permission_org
  (
<#assign prefixName=' '>
<#if (insert_id??) && (insert_id_value??)>
  ${prefixName} ID
	<#assign prefixName=','>
</#if>
<#if (insert_orgId??) && (insert_orgId_value??)>
  ${prefixName} ORG_ID
	<#assign prefixName=','>
</#if>
<#if (insert_permissionId??) && (insert_permissionId_value??)>
  ${prefixName} PERMISSION_ID
	<#assign prefixName=','>
</#if>
  )
  (
SELECT
<#assign prefixName=' '>
<#if (insert_id??) && (insert_id_value??)>
  ${prefixName} :insert_id_value
	<#assign prefixName=','>
</#if>
<#if (insert_orgId??) && (insert_orgId_value??)>
  ${prefixName} :insert_orgId_value
	<#assign prefixName=','>
</#if>
<#if (insert_permissionId??) && (insert_permissionId_value??)>
  ${prefixName} :insert_permissionId_value
	<#assign prefixName=','>
</#if>
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM c1_permission_org E
<#assign prefixName = 'WHERE'>
<#if (where_and_eq_id??)>
	<#if (where_and_eq_id_value??)>
${prefixName} E.ID = :where_and_eq_id_value
	<#else>
${prefixName} E.ID IS NULL
	</#if>
	<#assign prefixName = ''>
</#if>
<#if (prefixName!) != 'WHERE'>
	<#assign prefixName='AND'>
</#if>
<#if (where_and_eq_orgId??)>
	<#if (where_and_eq_orgId_value??)>
${prefixName} E.ORG_ID = :where_and_eq_orgId_value
	<#else>
${prefixName} E.ORG_ID IS NULL
	</#if>
	<#assign prefixName = ''>
</#if>
<#if (prefixName!) != 'WHERE'>
	<#assign prefixName='AND'>
</#if>
<#if (where_and_eq_permissionId??)>
	<#if (where_and_eq_permissionId_value??)>
${prefixName} E.PERMISSION_ID = :where_and_eq_permissionId_value
	<#else>
${prefixName} E.PERMISSION_ID IS NULL
	</#if>
	<#assign prefixName = ''>
</#if>
)
  )